package com.bbzn.device.client.utils;

import jodd.util.StringUtil;

public class GPSUtils {
    /**
     * 十进制经度转换 dddmm.mmmmm 转 ddd.ddddd
     * 如：112°30.4128 = 112.50688
     * @param jwd
     * @author Cai_YF
     * @return
     */
    public static String DDDmTurnD(String jwd){
        if(StringUtil.isNotEmpty(jwd)){//如果不为空并且存在度单位
            double d=0,m=0;
            d = Double.parseDouble(jwd.substring(0,3));
            m = Double.parseDouble(jwd.substring(3))/60;
            jwd = String.valueOf(d+m);
        }
        return jwd;
    }

    /**
     * 十进制经纬度转换 ddmm.mmmmm 转 ddd.ddddd
     * 如：112°30.4128 = 112.50688
     * @param jwd
     * @author Cai_YF
     * @return
     */
    public static String DDmTurnD(String jwd){
        if(StringUtil.isNotEmpty(jwd)){//如果不为空并且存在度单位
            double d=0,m=0;
            d = Double.parseDouble(jwd.substring(0,2));
            System.out.println(jwd.substring(2));
            m = Double.parseDouble(jwd.substring(2))/60;
            jwd = String.valueOf(d+m);
        }
        return jwd;
    }


    /*public static void main(String[] args) {
        String lonStr = "11351.07209";
        String lon = DDDmTurnD(lonStr);
        System.out.println("經度"+lon);

        String latStr = "2235.50315";
        String lat = DDmTurnD(latStr);
        System.out.println("緯度"+lat);
    }*/
}
